import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import React, { useEffect, useState } from "react";
import ConfigIndex from "./ConfigIndex";
import ConfigByStep from "./ConfigByStep";
import { pageEvents } from "../utils/event"; // language: zh_Cn, en_US

var ProdApp = function ProdApp() {
  var _useState = useState({
    path: "theme-config",
    params: {}
  }),
      _useState2 = _slicedToArray(_useState, 2),
      page = _useState2[0],
      setPage = _useState2[1];

  var pageMap = {
    "theme-config": ConfigIndex,
    "theme-config/components": ConfigByStep
  };
  useEffect(function () {
    pageEvents.on("push", function (path) {
      var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      setPage({
        path: path,
        params: params
      });
    });
  }, []);

  var DisplayPage = pageMap[page.path] || function () {
    return React.createElement("div", null, "404 Not Found");
  };

  return React.createElement(DisplayPage, page.params);
};

export default ProdApp;